package com.skycode5.bean;
import com.skycode5.dao.AdminDao;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/adminDel.jsp")
public class AdminDelServlet77 extends HttpServlet { @Override

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int AdminId = Integer.parseInt(req.getParameter("AdminId"));
        int result = (new AdminDao()).delete(AdminId);
        if (result > 0) {
            resp.sendRedirect("admin.jsp");
        }else {
            req.setAttribute("msg","删除失败");
            req.setAttribute("url","admin.jsp");
            try {
                req.getRequestDispatcher("WEB-INF/error.jsp").forward(req, resp);
            } catch (ServletException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

